package view
{
	import event.AssetsEvent;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	import util.AssetsManager;
	import util.GraphicsResource;
	import util.ResourceManager;
	
	/**
	 *普通的游戏对象（显示对象）
	*/
	public class GameObject extends BaseObject
	{
		
		public var position:Point = new Point(0,0);
		public var graphics:GraphicsResource = null;
		protected var activePolicy:Function;
		
		
		public function GameObject(activePolicy:Function)
		{
			this.activePolicy = activePolicy;
			super();
		}
		
		public function startUpGameObject(graphics:GraphicsResource,position:Point,layer:String):void {
			if(!inuse) {
				this.graphics = graphics;
				this.position = position;
				super.startUpBaseObject(layer);
			}
		}
		
		override public function copyToBackBuffer(db:BitmapData):void {
			db.copyPixels(graphics.bitmap, graphics.bitmap.rect, position, graphics.bitmapAlpha, new Point(0, 0), true);
		}
		
		override public function shutDown():void {
			if(inuse) {
				this.graphics = null;
				this.position.x = 0;
				this.position.y = 0;
				super.shutDown();
			}
		}
		
		override public function enterFrame(dt:Number):void {
			activePolicy(this,dt);
		}
	}
}